package com.example.databasepj.controller;

import com.example.databasepj.Request.LoginRequest;
import com.example.databasepj.dto.LoginResponse;
import com.example.databasepj.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/login")
public class LoginController {
    @Autowired
    private LoginService loginService;
    @PostMapping
    @ResponseBody
    public LoginResponse login(@RequestBody LoginRequest loginRequest) {
        LoginResponse response = loginService.Login(loginRequest.getId(), loginRequest.getPassword(),loginRequest.getRole());
        return response; // 直接返回LoginResponse对象，Spring Boot会自动将其转换为JSON
    }


}
